<script>
  import { push, location } from 'svelte-spa-router'
  // export let onAddClick
  // export let showAdd
  $: showAdd = $location === '/'
  const onAddClick = () => {
    push('/add/0')
  }
</script>

<nav class="nav">
  <div class="nav-center">
    <h1 class="nav-title">商品列表</h1>
    {#if showAdd}
      <button class="nav-btn" on:click|preventDefault={() => onAddClick()}>
        <i class="fa fa-plus-square"></i>
        添加商品
      </button>
    {/if}
  </div>
</nav>
